#include "LuxInfoPage.h"

#include "MachineDependents.h"
#include "LuxSensor.h"


LuxInfoPage::LuxInfoPage(const int pageNum) : BasePage(pageNum) {
    mpControllers = &ExtendDeviceManagerSingleton::instance().getExtendDevices(ExtendDeviceEnum::LUX);
}


void LuxInfoPage::paint() {
    std::string content[4];

    resetStream();

    strStream << std::left << std::setw(13) << "LuxInfo" << std::right << std::setw(3) << pageNum;
    content[0] = strStream.str();

    if (mpControllers->empty() ) {
        content[1] = ExtendDeviceEnum::NO_DEVICE.name;
    } else {
        ExtendDevicePtr extendDevicePtr = mpControllers->front().lock();
        if (nullptr == extendDevicePtr) {
            content[1] = ExtendDeviceEnum::NO_DEVICE.name;
        } else {

            LuxSensor* pLuxController = static_cast<LuxSensor*> (extendDevicePtr->getDevice(ExtendDeviceEnum::LUX));
            pLuxController->updateInformation();
            content[1] = "lux:";

            content[1].append(pLuxController->mluxString);
        }

    }
    screen.show(&content[0], &content[1], &content[2], &content[3]);
}




